#include "Ball.h"
#include "pal.h"
#include "pal/palFactory.h"
#include "pal/ConfigStatic.h"
namespace obstacles
{

Ball::Ball()
{
	position = new palVector3;
	size = 1.0;
	mass = 0.05;
}

Ball::~Ball()
{

}

palVector3 Ball::getPosition()
{
	palVector3 pos;
	body->GetPosition(pos);
	return pos;
}

void Ball::setPosition(float x, float y, float z)
{
	position->x = x;
	position->y = y;
	position->z = z;
}

void Ball::createPhysics()
{
	body = PF->CreateSphere();
	body->Init(position->x, position->y, position->z, size, mass); //
}

int Ball::getElementCount() {
	return 1;
}

ElementData Ball::getElementData(int index) {
	ElementData ed(SphereType);
	float *d = new float[1];
	d[0] = size;
	ed.setData(1,d);
	ed.setColor(255,255,255);
	palMatrix4x4 loc = body->GetLocationMatrix();
	ed.setTransformationMatrix(loc._mat);
	return ed;
}

void Ball::setScale(float x, float y, float z) {
	size = (x+y+z)/3;
}

void Ball::setMass(float mass) {
	this->mass = mass;
}
}

